package com.plian.system.dao.pm.property;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import com.plian.system.model.page.Page;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class PropertyRecordDao {
    @Resource(name = "daoSupport")
    private DaoSupport dao;

    /**
     * 新增
     * @param pd
     * @throws Exception
     */
    public void save(PageData pd) throws Exception {
        dao.save("PropertyRecordMapper.save",pd);
    }
    public void saveAll(List<PageData> list) throws Exception {
        dao.save("PropertyRecordMapper.saveAll",list);
    }

    public void delByIds(List<String> ids) throws Exception {
        dao.delete("PropertyRecordMapper.delByIds",ids);
    }


    /**
     * 修改
     * @param pd
     * @throws Exception
     */
    public void edit(PageData pd) throws Exception {
        dao.update("PropertyRecordMapper.edit",pd);
    }

    /**
     * * 根据Id获取最新的一条数据
     * @param id
     * @return
     * @throws Exception
     */
    public PageData findbyid(String id) throws Exception {
        return (PageData) dao.findForObject("PropertyRecordMapper.findbyid",id);
    }
    /**
     * * 根据初始Id获取最新的一条数据
     * @param initialId
     * @return
     * @throws Exception
     */
    public PageData newFindByid(String initialId) throws Exception {
        return (PageData) dao.findForObject("PropertyRecordMapper.newFindByid",initialId);
    }



    /**
     * 根据多单位查询列表
     * @param page
     * @return
     * @throws Exception
     */
    public List<PageData> reportListPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyRecordMapper.reportListPage",page);
    }
    public List<PageData> list(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyRecordMapper.list",pd);
    }
    public List<PageData> listPage(Page page) throws Exception {
        return (List<PageData>) dao.findForList("PropertyRecordMapper.listPage",page);
    }
    public List<PageData> treeList(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyRecordMapper.treeList",pd);
    }
    //获取某个时间点的一级及以上企业
    public List<PageData> getOneUnit(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PropertyRecordMapper.getOneUnit",pd);
    }

    public List<PageData> allList() throws Exception {
        return (List<PageData>) dao.findForList("PropertyRecordMapper.allList",null);
    }

    public void updateOrgCode(List<PageData> list) throws Exception {
        dao.batchSave("PropertyRecordMapper.updateOrgCode",list);
    }

    public List<PageData> allInfoList() throws Exception {
        return (List<PageData>) dao.findForList("PropertyRecordMapper.allInfoList",null);
    }

}
